/*
 * 
 *方法的整理与重构
 *
 *
 */

//定义app参数名称，并加载其它模块
var authApp=angular.module('authapp', ["ngCookies",'ngFileUpload','ui.bootstrap']);

//此为定位页面所用
authApp.value('page','opinionSummary_edit');

/*controller部分*/

//主要操作controller
authApp.controller("opinionEditController",function($scope,$http,$getQueryString,$timeout,$sce){
	$scope.schoolId=$getQueryString("schoolId");
	$scope.isfollow=$getQueryString("isfollow");
	$scope.isfollowVal="";
	$scope.anum=0;
	$scope.bnum=0;
	$scope.cnum=0;
	
	
	//**********主体方法
	$scope.checkIsfollow=function(){
		switch($scope.isfollow){
		case"0":$scope.isfollowVal="进入现场考察";
		break;
		case"1":$scope.isfollowVal="暂缓进入现场考察";
		break;
		case"2":$scope.isfollowVal="重新申报";
		}
	}
	$scope.checkIsfollow();
	
	$scope.ifFirstTimeQuery=true;
	
	var queryMainApi=apis.queryAuthCollect;	
	var requestJson={'schoolId':$scope.schoolId};	
	$scope.queryMain=function(){
		$http({
			method:'get',
			url:queryMainApi,
			params:requestJson,
		}).success(function(response){
			if(response.code=="000000"){
				$scope.queryMainApiCallBack(response);
			}else{
				alert(response.errorMsg);
			}
		}).error(function(){
			alert("网络出现故障，请确认网络是否连接");
		})
	}
	
	$scope.queryMain();
	
	/*下面为自已编辑部分*/
	
	//调用主接口成功之后的处理方法
	$scope.queryMainApiCallBack=function(response){
		if(response.code=="000000"){
			$scope.list=response.data;
			
			angular.forEach($scope.list,function(data,index,array){
				var t=index+1;
				if(data){
					var k=data.number
					angular.forEach(data.list,function(data,index,array){
						data.num=k+"-"+data.number;
						switch(data.level){
						case"A":$scope.anum++;
						break;
						case"B":$scope.bnum++;
						break;
						case"C":$scope.cnum++;
						break;
						}
					})
				}
			})
		}else{
			alert(response.errorMsg);
		}
	}
	
	/*
	 * 
	 * 其它操作方法
	 * 
	 */
	//返回到前页面
	$scope.goback=function(){
		if(window.confirm("是否确认返回？")){
			javascript:history.back(-1);
		}
	}
})
